{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "3f7d7fd0",
   "metadata": {},
   "source": [
    "------------\n",
    "* 时间：2022-09-05 week03\n",
    "* 学习记录人：yy\n",
    "* Python学习笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c20af115",
   "metadata": {},
   "source": [
    "# 本周学习目标"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "da483611",
   "metadata": {},
   "source": [
    "> 1. 模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1b0bb560",
   "metadata": {},
   "source": [
    "> 2. 变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7deb8d32",
   "metadata": {},
   "source": [
    "> 3. 循环遍历"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8070d11f",
   "metadata": {},
   "source": [
    "# 1.模块"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b488d880",
   "metadata": {},
   "source": [
    "## 1.1模块（[标准库](https://docs.python.org/3/library/time.html)）\n",
    "> python创始人团队为后面使用这门编程语言的人们提供的解决日常生活可能使用到的功能，而创建的模块。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3581a83e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import time"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "577b67e9",
   "metadata": {},
   "source": [
    "**纪元（1970.1.1）**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84bface2",
   "metadata": {},
   "source": [
    "**时间说**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "60abae28",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1662345863.7021494"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6fe0b20d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1662346066.953352"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.time()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1764a070",
   "metadata": {},
   "source": [
    "**当地时间**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a0adc2e5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=5, tm_hour=10, tm_min=47, tm_sec=24, tm_wday=0, tm_yday=248, tm_isdst=0)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.localtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e106ef5d",
   "metadata": {},
   "source": [
    "**国际标准时间**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c1853976",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=5, tm_hour=2, tm_min=48, tm_sec=6, tm_wday=0, tm_yday=248, tm_isdst=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.gmtime()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c844e5e6",
   "metadata": {},
   "source": [
    "**时间格式化 time.asctime**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a7a3580a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mon Sep  5 10:53:44 2022'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.asctime(time.localtime())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0f7a9223",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Mon Sep  5 02:56:30 2022'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "time.asctime(time.gmtime())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b0918b3",
   "metadata": {},
   "source": [
    "## 1.2模块（[开源模块](https://pypi.org/)）\n",
    "> 1. 因为代码开源\n",
    "> 2.集合全领域（全人类）的需求\n",
    "> 3. 按照国际标准开放的模块库"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d6f14f04",
   "metadata": {},
   "source": [
    "## 1.3 模块（自定义模块）\n",
    "> 1. 不愿意开源的，有一定知识产权的（开放的API租用形式开放）\n",
    "> 2. 自己用的，写的也不怎么好，开源出去丢人的"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b5f08554",
   "metadata": {},
   "source": [
    "# 2.变量"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5b11bf93",
   "metadata": {},
   "source": [
    "> 1. 变量用于存储要在计算机程序中引用和操作的信息\n",
    "> 2. 声明变量（命名）规则\n",
    ">> 1. 变量名只能是 字母、数字或下划线的任意组合\n",
    ">> 2. 变量名的第一个字符不能是数字\n",
    ">> 3. 以下关键字不能声明为变量名\n",
    "['and', 'as', 'assert', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'exec', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda','not', 'or', 'pass', 'print', 'raise', 'return', 'try', 'while', 'with', 'yield']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "9b18049d",
   "metadata": {},
   "outputs": [],
   "source": [
    "网三_01 = \"yy\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "ee168cb9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'yy'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网三_01"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "22d8d705",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1832823141296"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "id(网三_01)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "64ccc124",
   "metadata": {},
   "outputs": [],
   "source": [
    "yy_age = 19"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "565f717c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "19"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "yy_age"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "8cc899d1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2110440010 2110440010\n"
     ]
    }
   ],
   "source": [
    "# 案例（关于变量)\n",
    "\n",
    "yy_ID = \"2110440010\"\n",
    "\n",
    "tt_ID = yy_ID\n",
    "\n",
    "print(yy_ID,tt_ID)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "58988a5e",
   "metadata": {},
   "outputs": [],
   "source": [
    "yy_ID =\"2110440011\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "1e8e52b7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2110440011 2110440010\n"
     ]
    }
   ],
   "source": [
    "print(yy_ID,tt_ID)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2463b911",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Not an odd minute.\n"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odds = [  1,  3,  5,  7,  9,  11,  13,  15,  17,  19,\n",
    "         21, 23, 25, 27, 29,  31,  33,  35,  37,  39,\n",
    "         41, 43, 45, 47, 49,  51,  53,  55,  57,  59 ]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4a71eb18",
   "metadata": {},
   "source": [
    "# 课后作业"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "8d0f6035",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'odds' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "Input \u001b[1;32mIn [1]\u001b[0m, in \u001b[0;36m<cell line: 9>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      3\u001b[0m odd \u001b[38;5;241m=\u001b[39m [ \u001b[38;5;241m1\u001b[39m,  \u001b[38;5;241m3\u001b[39m,  \u001b[38;5;241m5\u001b[39m,  \u001b[38;5;241m7\u001b[39m,  \u001b[38;5;241m9\u001b[39m, \u001b[38;5;241m11\u001b[39m, \u001b[38;5;241m13\u001b[39m, \u001b[38;5;241m15\u001b[39m, \u001b[38;5;241m17\u001b[39m, \u001b[38;5;241m19\u001b[39m,\n\u001b[0;32m      4\u001b[0m        \u001b[38;5;241m21\u001b[39m, \u001b[38;5;241m23\u001b[39m, \u001b[38;5;241m25\u001b[39m, \u001b[38;5;241m27\u001b[39m, \u001b[38;5;241m29\u001b[39m, \u001b[38;5;241m31\u001b[39m, \u001b[38;5;241m33\u001b[39m, \u001b[38;5;241m35\u001b[39m, \u001b[38;5;241m37\u001b[39m, \u001b[38;5;241m39\u001b[39m,\n\u001b[0;32m      5\u001b[0m        \u001b[38;5;241m41\u001b[39m, \u001b[38;5;241m43\u001b[39m, \u001b[38;5;241m45\u001b[39m, \u001b[38;5;241m47\u001b[39m, \u001b[38;5;241m49\u001b[39m, \u001b[38;5;241m51\u001b[39m, \u001b[38;5;241m53\u001b[39m, \u001b[38;5;241m55\u001b[39m, \u001b[38;5;241m57\u001b[39m, \u001b[38;5;241m59\u001b[39m ]\n\u001b[0;32m      7\u001b[0m right_this_minute \u001b[38;5;241m=\u001b[39m datetime\u001b[38;5;241m.\u001b[39mtoday()\u001b[38;5;241m.\u001b[39mminute\n\u001b[1;32m----> 9\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m right_this_minute \u001b[38;5;129;01min\u001b[39;00m \u001b[43modds\u001b[49m:\n\u001b[0;32m     10\u001b[0m     \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThis minute seems a little odd.\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m     11\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n",
      "\u001b[1;31mNameError\u001b[0m: name 'odds' is not defined"
     ]
    }
   ],
   "source": [
    "from datetime import datetime\n",
    "\n",
    "odd = [ 1,  3,  5,  7,  9, 11, 13, 15, 17, 19,\n",
    "       21, 23, 25, 27, 29, 31, 33, 35, 37, 39,\n",
    "       41, 43, 45, 47, 49, 51, 53, 55, 57, 59 ]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"This minute seems a little odd.\")\n",
    "else:\n",
    "    print(\"Not an odd minute.\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba7888b8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
